package com.learn.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


import com.learn.dao.InsureDao;
import com.learn.entity.InsureEntity;
import com.learn.service.InsureService;
import com.learn.service.*;


@Service("insureService")
public class InsureServiceImpl implements InsureService {
    @Autowired
    private InsureDao insureDao;


    @Autowired
    private TypeService typeService;


    @Override
    public InsureEntity queryObject(Long id) {
        InsureEntity entity = insureDao.queryObject(id);


        if (entity.getType() != null && this.typeService.queryObject(entity.getType()) != null)
            entity.setTypeEntity(this.typeService.queryObject(entity.getType()));


        return entity;
    }

    @Override
    public List<InsureEntity> queryList(Map<String, Object> map) {
        List<InsureEntity> list = insureDao.queryList(map);
        for (InsureEntity entity : list) {

            if (entity.getType() != null && this.typeService.queryObject(entity.getType()) != null)
                entity.setTypeEntity(this.typeService.queryObject(entity.getType()));

        }
        return list;
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return insureDao.queryTotal(map);
    }

    @Override
    public void save(InsureEntity insure) {
        insureDao.save(insure);
    }

    @Override
    public void update(InsureEntity insure) {
        insureDao.update(insure);
    }

    @Override
    public void delete(Long id) {
        insureDao.delete(id);
    }

    @Override
    public void deleteBatch(Long[] ids) {
        insureDao.deleteBatch(ids);
    }

}
